package com.itheima.dubbo.web;

import com.itheima.dubbo.UserInterface;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 1.如果相同的配置在提供方和消费方都同时配置，则消费方优于提供方
 */
@RestController
@RequestMapping("user")
public class UserController {
   // @DubboReference(timeout = 5000) //远程调用
    @DubboReference
    UserInterface userInterface;
    @GetMapping("hello")
    public String hello (String username){
        RpcContext.getContext().setAttachment("jwt","hjjjjkkkkk");
        String result = userInterface.hello(username);
        return result;
    }

}
